let CreateNode = function (val) {
  this.val = val
  this.next = null
}

let CreatSingleLine = function (arr) {
  if (!Array.isArray(arr) || (Array.isArray(arr) && arr.length === 0)) {
    return null
  }

  let head = new CreateNode(arr[0])
  let cur = head

  for (let i = 1; i < arr.length; i++) {
    cur.next = new CreateNode(arr[i])
    cur = cur.next
  }

  return head
}

console.log(CreatSingleLine([1,2,3]));

